package com.moujitx.wecom.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.moujitx.wecom.repository.WecomConfigRepository;

import lombok.extern.slf4j.Slf4j;

/**
 * 数据初始化类，用于在应用启动时执行初始化操作
 */
@Component
@Slf4j
public class DataInitializer implements CommandLineRunner {

    @Autowired
    private WecomConfigRepository wecomConfigRepository;

    @Override
    public void run(String... args) throws Exception {
        // 检查是否有配置数据
        long count = wecomConfigRepository.count();
        
        if (count == 0) {
            log.info("数据库中没有企业微信配置，请通过Web界面或API添加配置");
        } else {
            log.info("数据库中已有 {} 条企业微信配置", count);
        }
    }
}